<template>
  <div class="login">
    <div class="login_a">
      <div class="login_a_a">
        <div class="login_a_a_a">
          <div class="login_a_a_a_a">
            <img src="../assets/imgs/1654871744407.fab7fcb8.png" alt="" />
          </div>
          <div class="login_a_a_a_b">大学生就业管理系统</div>
        </div>
        <div class="login_a_a_b">
          <div class="login_a_a_b_a">
            <span>管理员登录</span>
            <!-- <router-link to="register">
                            注册
            </router-link> -->
          </div>
          <p></p>
          <div>
            <span>账 &nbsp;&nbsp;号:</span>
            <span><input v-model="uname" type="text" /></span>
          </div>
          <p>提示</p>
          <div>
            <span>密 &nbsp;&nbsp;码:</span>
            <span
              ><input @keyup.enter="getdata" v-model="upwd" type="password"
            /></span>
          </div>
          <p>提示</p>
          <div>
            <span> 30天免登:<input type="checkbox" /> </span>
            <span> </span>
          </div>
          <p></p>
          <div class="login_list">
            <div @click="getdata">登录</div>
            <div>忘记密码</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      uname: "",
      upwd: "",
    };
  },
  methods: {
    getdata() {
      let param = `uname=${this.uname}&upwd=${this.upwd}`;
      let url = "/v1/users/loginBase";
      this.axios.post(url, param).then((res) => {
        // console.log(res);
        if (res.data.msg == 200) {
          // 把用户名存储在全局里
          this.$store.commit("updateLoginState", this.uname);
          alert("登录成功");
          this.$router.push("/index");
        } else {
          alert("登录失败,用户名或者密码错误");
          this.upwd = "";
        }
      });
    },
  },
};
</script>

<style scoped src="../assets/css/login.css">
</style>
<style lang="scss" scoped>
</style>